package  
{
	import flash.display.MovieClip;
	import com.greensock.*;
	import flash.events.Event;
	/**
	 * ...
	 * @author KhanhNHV
	 */
	public class PlayField  extends MovieClip 
	{
		
		public function PlayField() 
		{
			createSquare();
			this.addEventListener("SpecialBlockFocused", specialWordsFocused);
		}
		
		public function  specialWordsFocused(evt:Event):void 
		{
			for (var i = 0; i < this.numChildren; i++)
			{
				var sqrBlock:SquareTextBlock = this.getChildAt(i) as SquareTextBlock;
				sqrBlock.highlightSpecialSquare();
			}
		}
		
		public function createSquare()
		{
			var sqrBlock:SquareTextBlock;
			//text 1
			sqrBlock = new SquareTextBlock("WORLDBANK", 9, 0, 0);
			sqrBlock.index = 0;
			sqrBlock.name = "Block " + sqrBlock.index;
			this.addChild(sqrBlock);
			//TEXT 2
			sqrBlock = new SquareTextBlock("DEFAULTRISK", 6, 1, 3);
			sqrBlock.index = 1;
			this.addChild(sqrBlock);
			//TEXT 3
			sqrBlock = new SquareTextBlock("UTILITY", 6, 2, 3);
			sqrBlock.index = 2;
			this.addChild(sqrBlock);
			//TEXT 4
			sqrBlock = new SquareTextBlock("INFLATION", 6, 3, 3);
			sqrBlock.index = 3;
			this.addChild(sqrBlock);
			//TEXT 5
			sqrBlock = new SquareTextBlock("SHAREOPTION", 9, 4, 0);
			sqrBlock.index = 4;
			this.addChild(sqrBlock);
			//TEXT 6
			sqrBlock = new SquareTextBlock("VIETINBANK", 6, 5, 3);
			sqrBlock.index = 5;
			this.addChild(sqrBlock);
			//TEXT 7
			sqrBlock = new SquareTextBlock("SPECULATOR", 0, 6, 9);
			sqrBlock.index = 6;
			this.addChild(sqrBlock);
			//TEXT 8
			sqrBlock = new SquareTextBlock("DIVERSIFICATION", 6, 7, 3);
			sqrBlock.index = 7;
			this.addChild(sqrBlock);
			//TEXT 9
			sqrBlock = new SquareTextBlock("DIVIDEND", 4, 8, 5);
			sqrBlock.index = 8;
			this.addChild(sqrBlock);			
			//TEXT 10
			sqrBlock = new SquareTextBlock("STOCKEXCHANGE", 8, 9, 1);
			sqrBlock.index = 9;
			this.addChild(sqrBlock);			
			
		}
		
		public function minimize():void
		{
			TweenLite.to(this, 1.2, { scaleX:0.4, scaleY:0.4, x:710, y:670 } );
			
		}
		
		public function maximize()
		{
			TweenLite.to(this, 1.2, { scaleX:1, scaleY:1, x:0, y:100 } );
		}
		
	}

}